﻿using System;
using System.Collections.Generic;

using E.Model;
using E.BLL;
using E.Web.UI.Page;

using X.Pager;
using X.Pager.List;
using X.Common;

namespace E.Web.training.frames
{
    public partial class Management : BasePage
    {
        public IList<ShortNoticeModel> noticeList;
        public IList<StudyLogForListModel> studyList;
        public int newQnACount = 0;

        protected override void ShowPage()
        {
            SearchNoticeModel searchModel = new SearchNoticeModel();
            searchModel.Title = "";
            searchModel.CategoryID = -1;
            searchModel.PublisherID = -1;
            searchModel.SysSelection = 0;
            searchModel.FromDate = "";
            searchModel.ToDate = "";
            searchModel.AreaID = areaid;
            searchModel.CertificateID = authority == E.Enum.EnumUserAuthority.Internal ? (new UserBLL()).GetUserProjectID(userid) : -1;

            NoticeListModel noticeListModel = new NoticeListModel();

            noticeListModel = (new NoticeBLL()).GetNoticeListByCondition(searchModel, config.DefaultShortNoticeQuantity, 0);

            noticeList = noticeListModel.List;

            if (authority == E.Enum.EnumUserAuthority.Public)
            {

                SearchStudyLogModel model = new SearchStudyLogModel();
                StudyBLL bll = new StudyBLL();
                model.CourseName = "";
                model.CourseCategoryID = -1;
                model.StartFromTime = "";
                model.StartToTime = "";
                model.EndFromTime = "";
                model.EndToTime = "";
                model.UserID = userid;

                StudyLogListModel listModel = new StudyLogListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                //listModel = bll.SearchClassByCondition(model, customerPageSize, pageIndex);
                listModel = bll.GetStudyLogByCondition(model, customerPageSize, pageIndex);

                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    studyList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);
                    pager.PageSizeEnable = false;
                    mypager = pager.DrawPager("selfpager");
                }
            }

            newQnACount = (new TeacherBLL()).GetNewReplyQnACount(userid);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
